Những câu hỏi liên quan
huy123
Xem chi tiết
giapducphuongth2601
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 12 2021 lúc 10:48

a: 

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t1,t2;

int main()

{

cin>>n;

t1=0;

t2=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0) t1=t1+x;

else t2=t2+x;

}

cout<<t1<<" "<<t2;

return 0;

}

Bình luận (0)
Đại Hà
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 12 2021 lúc 10:05

a: #include <bits/stdc++.h>

using namespace std;

unsigned long long int n,i,t1,t2,x;

int main()

{

cin>>n;

t1=0;

t2=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0) t1=t1+x;

else t2=t2+x;

}

cout<<t1<<endl;

cout<<t2;

return 0;

}

Bình luận (0)
my trần
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 8 2021 lúc 19:15

uses crt;

var a:array[1..100]of integer;

i,n,dem,max,t,min,dem1:integer;

begin

clrscr;

write('n='); readln(n);

for i:=1 to n do 

 begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

max:=-32000;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then 

begin

dem:=dem+1;

if max<a[i] then max:=a[i];

end;

if dem=0 then writeln('Trong day khong co so chan')

else begin

writeln('So so chan la: ',dem);

writeln('So chan lon nhat la: ',max);

end;

t:=0;

for i:=1 to n do 

  if i mod 2=1 then t:=t+a[i];

writeln('Tong cac so o vi tri le la: ',t);

min:=maxint;

dem1:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then

begin  

inc(dem1);

if min>a[i] then min:=a[i];

end;

if dem1=0 then writeln('Trong day khong co so le')

else writeln('So le nho nhat la: ',min);

readln;

end. 

Bình luận (0)
Thảo Nguyên 36-88
Xem chi tiết
JamesDang
26 tháng 3 2022 lúc 20:01

uses crt;
var a: array[1..100] of longint;
    i,n,max,min: longint;

begin
    clrscr;
    readln(n);
    for i:=1 to n do
    begin
        write('Nhap so thu ',i,': '); 
        readln(a[i]);
    end;
    max:=a[1]; min:=a[1];
    for i:=1 to n do
    begin
        if max<a[i] then max:=a[i];
        if min>a[i] then min:=a[i];
    end;
    writeln('So lon nhat trong mang la: ',max);
    write('So nho nhat trong mang la: ',min);
    readln
end.

Bình luận (0)
35.Nguyễn Phương thanh
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 2 2022 lúc 22:49

#include <bits/stdc++.h>

using namespace std;

long long a[150],i,s,n,nn;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

s=1;

for (i=1; i<=n; i++) 

if (a[i] %2!=0 && a[i]%3==0) s=s*a[i];

cout<<s<<endl;

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

for (i=n; i>=1; i--) 

if (nn==a[i]) 

{

cout<<i<<endl;

break;

}

sort(a+1,a+n+1);

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Phương Vũ Hà
Xem chi tiết
Nguyễn Lê Phước Thịnh
1 tháng 3 2021 lúc 17:19

uses crt;

var a:array[1..100]of integer;

n,i,k,max,min,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

write('Nhap k='); readln(k);

max:=a[1];

for i:=1 to n do 

  if max<a[i] then max:=a[i];

writeln('Gia tri lon nhat la: ',max);

writeln('Vi tri la: ');

for i:=1 to n do 

  if max=a[i] then write(i:4);

writeln;

min:=a[1];

for i:=1 to n do

  if min>a[i] then min:=a[i];

writeln('Gia tri nho nhat la: ',min);

writeln('Vi tri la: ');

for i:=1 to n do

if min=a[i] then write(i:4);

writeln;

t:=0;

for i:=1 to n do 

  if i mod 2=0 then t:=t+sqr(a[i]);

writeln('Tong binh phuong cac gia tri o vi tri chan la: ',t);

readln;

end. 

Bình luận (0)
Lê Thị Bảo Trâm
Xem chi tiết
Trần Đức Huy
6 tháng 2 2022 lúc 11:49

Chương trình nhập n và mảng hay nhập mảng chưa biết số hạng tử v

Bình luận (0)
Nguyễn Lê Phước Thịnh
6 tháng 2 2022 lúc 12:43

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,ln,t1,dem,s;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

ln=a[1];

for (i=1; i<=n; i++) ln=max(ln,a[i]);

cout<<ln<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];

cout<<t<<endl;

dem=0;

for (i=1; i<=n; i++) if (a[i]<0) dem++;

cout<<dem<<" ";

s=1;

for (i=1; i<=n; i++)

if ((a[i]%3==0) and (a[i]>0)) s=s*a[i];

cout<<s;

return 0;

}

Bình luận (1)
Kiều Vũ Linh
7 tháng 2 2022 lúc 8:37

Var a:array[1..200] of integer;

i,n,max,s1,dem,s2:integer;

begin

write('Nhap so luong phan tu cua mang n = ');readln(n);

for i:=1 to n do

begin

write('Nhap phan tu thu ',i,' = ');readln(a[i]);

end;

max:=a[1];

for i:=2 to n do

if a[i] > max then max:=a[i];

for i:=1 to n do

begin

if a[i] mod 2 = 0 then s1:=s1+a[i];

end;

for i:=1 to n do

begin

if a[i] < 0 then dem:=dem + 1;

end;

s2:=1;

for i:=1 to n do

begin

if (a[i] > 0) and (a[i] mod 3 = 0) then s2:=s2*a[i];

end;

writeln('gia tri lon nhat trong mang la ',max);

writeln('tong cac so chan la ',s1);

writeln('Co ',dem,' so am');

write('tich cac so duong va chia het cho 3 la ',s2);

end;

readln;

end.

Bình luận (0)
erddedfrferf ffvf fd
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 2 2022 lúc 16:53

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,nn;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) if (a[i]%2!=0) cout<<i<<" ";

cout<<endl;

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn<<endl;

for (i=1; i<=n; i++) if (nn==a[i]) cout<<i<<" ";

return 0;

}

Bình luận (2)